//
//  ScoreViewController.m
//  Elimination
//
//  Created by A-01 on 2020/7/6.
//  Copyright © 2020 A-01. All rights reserved.
//

#import "ScoreViewController.h"

@interface ScoreViewController ()

@property (nonatomic, weak)UILabel * titleLab;
@property (nonatomic, weak)UILabel * scoreLab;
@property (nonatomic, weak)UIButton * restartBtn;
@property (nonatomic, weak)UIButton * backBtn;

@end

@implementation ScoreViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.backButton.hidden = YES;
    [self setupUI];
}


- (void)setupUI{
    
    UILabel * titleLab = [UILabel new];

    titleLab.text = @"Current score";
    titleLab.textColor = [UIColor colorWithHexString:@"4198FF"];
    titleLab.font = [UIFont boldSystemFontOfSize:24];
    titleLab.textAlignment = NSTextAlignmentCenter;
            
    self.titleLab = titleLab;
            
    [self.view addSubview:self.titleLab];
    
    
    UILabel * scoreLab = [UILabel new];
        
    scoreLab.text = self.score;
    scoreLab.textColor = [UIColor colorWithHexString:@"4198FF"];
    scoreLab.font = [UIFont boldSystemFontOfSize:55];
    scoreLab.textAlignment = NSTextAlignmentCenter;
            
    self.scoreLab = scoreLab;
            
    [self.view addSubview:self.scoreLab];
    
    
    UIButton * restartButton = [[UIButton alloc] init];
    
    [restartButton setBackgroundColor:[UIColor colorWithHexString:@"4198FF"]];
    [restartButton setTitle:@"Restart" forState:UIControlStateNormal];
    [restartButton setTitleColor:ZRWhiteColor forState:UIControlStateNormal];
    [restartButton addTarget:self action:@selector(restartButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    restartButton.titleLabel.font = [UIFont fontWithName:@"FZSEJW--GB1-0" size:24];
    restartButton.layer.cornerRadius = 24;
    restartButton.layer.masksToBounds = YES;
    
    self.restartBtn = restartButton;
    
    [self.view addSubview:self.restartBtn];
    
    
    UIButton * backBtn = [[UIButton alloc] init];
    
    [backBtn setBackgroundColor:[UIColor colorWithHexString:@"4198FF"]];
    [backBtn setTitle:@"Back" forState:UIControlStateNormal];
    [backBtn setTitleColor:ZRWhiteColor forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(backButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    backBtn.titleLabel.font = [UIFont fontWithName:@"FZSEJW--GB1-0" size:24];
    backBtn.layer.cornerRadius = 24;
    backBtn.layer.masksToBounds = YES;
    
    self.backBtn = backBtn;
    
    [self.view addSubview:self.backBtn];
    
}


- (void)restartButtonClicked{
    
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)backButtonClicked{
    
    [self.navigationController popToRootViewControllerAnimated:YES];
}



- (void)viewDidLayoutSubviews{

    [super viewDidLayoutSubviews];

    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(self.view).offset(70);
    }];
    
    [self.scoreLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(self.titleLab.mas_bottom).offset(10);
    }];
    
    [self.restartBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(self.titleLab.mas_bottom).offset(105);
        make.width.mas_equalTo(245);
        make.height.mas_equalTo(48);
    }];
    
    [self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.width.height.mas_equalTo(self.restartBtn);
        make.top.mas_equalTo(self.restartBtn.mas_bottom).offset(25);
    }];
}



@end
